define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'zhongzhuan/baiying/byaitask/index' + location.search,
                    add_url: 'zhongzhuan/baiying/byaitask/add',
                    edit_url: 'zhongzhuan/baiying/byaitask/edit',
                    del_url: 'zhongzhuan/baiying/byaitask/del',
                    multi_url: 'zhongzhuan/baiying/byaitask/multi',
                    import_url: 'zhongzhuan/baiying/byaitask/import',
                    table: 'ec_ai_task',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                sortOrder:'asc',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),searchable:false},
                        {field: 'callJobId', title: __('Calljobid'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'jobName', title: __('Jobname'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'jobType', title: __('Jobtype')},

                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
                        
                        {field: 'callJobStatus', title: __('Calljobstatus'), 
                            searchList: {"0":__('calljobstatus 0'),"1":__('calljobstatus 1'),"2":__('calljobstatus 2'),"3":__('calljobstatus 3'),"4":__('calljobstatus 4'),"5":__('calljobstatus 5')
                            ,"6":__('calljobstatus 6'),"7":__('calljobstatus 7'),"8":__('calljobstatus 8'),"9":__('calljobstatus 9'),"10":__('calljobstatus 10')
                            }, 
                            formatter: Table.api.formatter.status},                        
                        {field: 'totalCount', title: __('Totalcount'),searchable:false, operate: 'LIKE'},
                        {field: 'doneCount', title: __('Donecount'),searchable:false, operate: 'LIKE'},
//                        {field: 'calledCount', title: __('Calledcount'),searchable:false, operate: 'LIKE'},
//                        {field: 'rejectedCount', title: __('Rejectedcount'),searchable:false, operate: 'LIKE'},
//                        {field: 'unavailableCount', title: __('Unavailablecount'),searchable:false, operate: 'LIKE'},
//                        {field: 'fromUnavailableCount', title: __('Fromunavailablecount'),searchable:false, operate: 'LIKE'},
                        {field: 'callJobStatusDesc', title: __('Calljobstatusdesc'),searchable:false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
//                        {field: 'remark', title: __('Remark'),searchable:false, operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'startDate', title: __('Startdate'),searchable:false, formatter: Table.api.formatter.datetime},
//                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
